package fun.tan90.easy.binlog.worker.handler;

import com.github.benmanes.caffeine.cache.LoadingCache;
import fun.tan90.easy.binlog.base.constants.EasyBinlogConstants;
import fun.tan90.easy.binlog.base.strategy.AbstractExecuteStrategy;
import fun.tan90.easy.binlog.plugin.common.model.OutputParam;
import lombok.extern.slf4j.Slf4j;
import org.noear.socketd.transport.core.Message;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * description TODO
 * company 铁人科技
 *
 * @author 陈浩杰
 * @date 2023/12/15 19:42
 */
@Slf4j
@Component
public class DeleteOutputParamHandler implements AbstractExecuteStrategy<Message, Void> {

    @Resource
    LoadingCache<String, OutputParam> outputParamCache;

    @Override
    public String mark() {
        return EasyBinlogConstants.DELETE_OUTPUT_PARAM;
    }

    @Override
    public void execute(Message message) {
        outputParamCache.invalidate(message.dataAsString());
    }
}
